package com.hfut.jpoa.dao.impl;

import java.sql.SQLException;

import com.hfut.jpoa.common.exception.DaoException;
import com.hfut.jpoa.dao.QuoteProductDAO;
import com.hfut.jpoa.model.QuoteProduct;
import com.ibatis.sqlmap.client.SqlMapClient;

public class QuoteProductDAOImpl implements QuoteProductDAO
{
	private SqlMapClient sqlMapClient;

	public int deleteByPrimaryKey(Integer quoteprdId) throws DaoException
	{
		QuoteProduct key = new QuoteProduct();
		key.setQuoteprdId(quoteprdId);
		int rows = 0;
        try
        {
	        rows = sqlMapClient
	                .delete("tb_jpoa_quote_product.ibatorgenerated_deleteByPrimaryKey",
	                        key);
        } catch (SQLException e)
        {
	        // TODO Auto-generated catch block
	        e.printStackTrace();
        }
		return rows;
	}

	public void insert(QuoteProduct record) throws DaoException
	{
		try
        {
	        sqlMapClient.insert("tb_jpoa_quote_product.ibatorgenerated_insert",
	                record);
        } catch (SQLException e)
        {
	        // TODO Auto-generated catch block
	        e.printStackTrace();
        }
	}

	public void insertSelective(QuoteProduct record) throws DaoException
	{
		try
        {
	        sqlMapClient
	                .insert("tb_jpoa_quote_product.ibatorgenerated_insertSelective",
	                        record);
        } catch (SQLException e)
        {
	        // TODO Auto-generated catch block
	        e.printStackTrace();
        }
	}

	public QuoteProduct selectByPrimaryKey(Integer quoteprdId)
	        throws DaoException
	{
		QuoteProduct key = new QuoteProduct();
		key.setQuoteprdId(quoteprdId);
		QuoteProduct record = null;
        try
        {
	        record = (QuoteProduct) sqlMapClient
	                .queryForObject(
	                        "tb_jpoa_quote_product.ibatorgenerated_selectByPrimaryKey",
	                        key);
        } catch (SQLException e)
        {
	        // TODO Auto-generated catch block
	        e.printStackTrace();
        }
		return record;
	}

	public int updateByPrimaryKeySelective(QuoteProduct record)
	        throws DaoException
	{
		int rows = 0;
        try
        {
	        rows = sqlMapClient
	                .update("tb_jpoa_quote_product.ibatorgenerated_updateByPrimaryKeySelective",
	                        record);
        } catch (SQLException e)
        {
	        // TODO Auto-generated catch block
	        e.printStackTrace();
        }
		return rows;
	}

	public int updateByPrimaryKey(QuoteProduct record) throws DaoException
	{
		int rows = 0;
        try
        {
	        rows = sqlMapClient.update(
	                "tb_jpoa_quote_product.ibatorgenerated_updateByPrimaryKey",
	                record);
        } catch (SQLException e)
        {
	        // TODO Auto-generated catch block
	        e.printStackTrace();
        }
		return rows;
	}

	public SqlMapClient getSqlMapClient()
	{
		return sqlMapClient;
	}

	public void setSqlMapClient(SqlMapClient sqlMapClient)
	{
		this.sqlMapClient = sqlMapClient;
	}
}